<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.css" rel="stylesheet" />
		<link href="../css/main.css" rel="stylesheet" />
	</head>

	<body>
		<script src="../js/mui.js"></script>
		<script type="text/javascript" charset="UTF-8">
			mui.init()
		</script>

		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title"></h1>
		</header>
		<div class="mui-content">
			<div id="msg">此处为聊天消息</div>
			<button type="button" id="gallery" class="mui-btn mui-btn-blue">相册</button>
			<button type="button" id="camera" class="mui-btn mui-btn-green">摄像头</button>
			<button type="button" id="getacc" class="mui-btn mui-btn-green">重力感应</button>
		</div>

	</body>

</html>

<script type="text/javascript">
	mui.plusReady(function() {
		var cw = plus.webview.currentWebview();
		var titleName = cw.title;
		var header = document.querySelector(".mui-title");
		header.innerText = titleName;
	})

	var msgDom = document.getElementById("msg");

	var galleryBtn = document.getElementById("gallery");
	galleryBtn.addEventListener("tap", function() {
		plus.gallery.pick(
			function(path) {
				var img = "";
				for(var i in path.files)
					img += "<img width=100 height=100 src=" + path.files[i] + ">";
				msgDom.innerHTML = img;
			},
			function(e){
				msgDom.innerHTML=e.message;
			},{
				filter:"image",
				multiple:true
			}
		)
	})
	
	var cmDom = document.getElementById("camera");
	cmDom.addEventListener("tap",function(){
		var cm = plus.camera.getCamera(1);
		cm.captureImage(function(path){
			var url="file://"+plus.io.convertLocalFileSystemURL(path);
			var img="<img width=100 height=100 src="+url+">";
			msgDom.innerHTML = img;
			
		})
	})
	//摇一摇功能
	// var accDom = document.getElementById("getacc");
	// accDom.addEventListener("tap",function(e){
	// 	plus.accelerometer.getCurrentAcceleration(function(a){
	// 		var msg=document.getElementById("msg");
	// 		msg.innerText="x:"+a.xAxis+"\n y:"+a.yAxis+"\n z:"+a.zAxis;
	// 	})
	// })
	
</script>
